﻿package control
{
    import com.core.*;
    import com.greensock.*;

    public class DangerControl extends Control
    {
        private var _tween:TweenLite;

        public function DangerControl(param1:Object)
        {
            super(param1);
            return;
        }// end function

        override public function update(param1:Obproxy, param2:ProxyChange) : void
        {
            if (param1.getName() == "danger")
            {
                if (param2.property == "show")
                {
                    if (target.visible == false)
                    {
                        target.visible = true;
                        target.alpha = 0.8;
                        if (!this._tween)
                        {
                            this.nextStep1();
                        }
                    }
                }
                else if (param2.property == "close")
                {
                    if (target.visible == true)
                    {
                        target.visible = false;
                        if (this._tween)
                        {
                            this._tween.kill();
                            this._tween = null;
                        }
                    }
                }
            }
            return;
        }// end function

        private function nextStep() : void
        {
            this._tween = TweenLite.to(target, 1, {alpha:0.8, onComplete:this.nextStep1});
            var _loc_1:* = ModelProxy.getValue("localCache", "option");
            if (_loc_1.offbasesound != 1)
            {
                ModelProxy.change("main", "playsound", "danger");
            }
            return;
        }// end function

        private function nextStep1() : void
        {
            this._tween = TweenLite.to(target, 1, {alpha:0.2, onComplete:this.nextStep});
            return;
        }// end function

    }
}
